package com.ruoyi.common.enums;

import java.util.Objects;

/**
 * 删除标记
 *
 * @author ruoyi
 **/
public enum DelFlagEnum implements BaseEnum<Integer, String> {

    /**
     * 未删除
     */
    NO(0, "未删除"),

    /**
     * 已删除
     */
    YES(1, "已删除");
    /**
     * 编码
     */
    private Integer code;

    /**
     * 描述
     */
    private String desc;

    DelFlagEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据CODE找枚举.
     *
     * @param code code
     * @return enum
     */
    public static DelFlagEnum getByCode(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        for (DelFlagEnum type : values()) {
            if (Objects.equals(type.getCode(), code)) {
                return type;
            }
        }
        return null;
    }

    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getDesc() {
        return this.desc;
    }
}
